package com.sms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sms.mapper.ProductsMapper;
import com.sms.pojo.Products;
import com.sms.service.ProductsService;
import com.sms.util.SqlSessionFactoryUtil;
import lombok.Getter;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

@Getter
public class ProductsServiceImpl extends ServiceImpl<ProductsMapper, Products> implements ProductsService {
    SqlSession sqlSession=null;
    @Override
    public ProductsMapper getBaseMapper() {
        sqlSession= SqlSessionFactoryUtil.getFactory().openSession(true);
        ProductsMapper mapper = SqlSessionFactoryUtil.getFactory().getConfiguration().getMapper(ProductsMapper.class, sqlSession);
        return mapper;
    }

    @Override
    public List<Products> listProducts() {
        return this.getBaseMapper().listProducts();
    }

    public List<Products> listProductsByName(String productName){
        return this.getBaseMapper().listProductsByName(productName);
    }

}